<template>

		
		<div>
			<mt-header fixed title="登陆"></mt-header>
			<div class="page-title">Header</div>
			<mt-field label="手机号" placeholder="请输入手机号" v-model="phoneNum"></mt-field>
			<mt-field label="密码" placeholder="请输入密码" type="password" v-model="password"></mt-field>
			<mt-button type="primary" size="large" style="margin-top: 5%;" @click="login">登陆</mt-button>
		</div>

</template>
<script>
	import { Toast,MessageBox,Navbar,TabItem,TabContainer,TabContainerItem } from "mint-ui";
	import state from '../../../vuex/state.js'
	export default {
		name: "login",
		data() {
			return {
				phoneNum: "",
				password: ""
			}
		},
		methods: {
			login() {
				var _this = this;
				 _this.$http.get('/api/user/login',{
					params: {
						phone: _this.phoneNum,
						pwd:  _this.password
					}  
				})
				.then(res => {
					console.log(res.body.data)
					if(res.body.info == "success"){
						Toast({
						  message: "欢迎您登陆vivo商城",
						  iconClass: "iconfont icon-success",
						  duration: 950
						});
						this.$store.dispatch("setUser",res.body.data)
						// this.$router.push({path:'my'})
						this.$router.go(-1);
					}else{
						Toast({
						  message: "登陆失败，请重新输入",
						  iconClass: "iconfont icon-error",
						  duration: 950
						});
					}
					
					
				}).catch(err => {
					console.log(err)
				});
			}
		}
	}
</script>

<style>
</style>
